package com.cr.admin.business.news.service.impl;


import com.cr.admin.business.news.dao.mapper.NewsMapper;
import com.cr.admin.business.news.dao.repository.NewsRepository;
import com.cr.admin.business.news.pojo.entity.News;
import com.cr.admin.business.news.pojo.param.NewsCreateParam;
import com.cr.admin.business.news.pojo.param.NewsSearchParam;
import com.cr.admin.business.news.pojo.query.NewsQuery;
import com.cr.admin.business.news.pojo.vo.NewsCategoryVO;
import com.cr.admin.business.news.pojo.vo.NewsDetailsVO;
import com.cr.admin.business.news.pojo.vo.NewsListVO;
import com.cr.admin.business.news.pojo.vo.NewsStatusVO;
import com.cr.admin.business.news.service.NewsService;
import com.cr.admin.business.topic.pojo.entity.Topic;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Slf4j
@Service
public class NewsServiceImpl implements NewsService {

    @Autowired
    private NewsRepository newsRepository;


//    @Override
//    public List<NewsListVO> getNewsList(int page, int size) {
//        return newsRepository.selectByTimeDesc(page,size);
//    }

    @Override
    public List<NewsCategoryVO> getNewsCategory() {

        return newsRepository.selectCategory();
    }

    @Override
    public List<NewsStatusVO> getNewsStatus() {
        return newsRepository.selectNewsStatus();
    }


    @Override
    public List<News> list(NewsQuery newsQuery) {
        return newsRepository.selectList(newsQuery);
    }

    @Override
    public NewsDetailsVO getNewsDetails(Integer id) {
        return newsRepository.selectDetailsById(id);
    }

    @Override
    public void saveCreate(NewsCreateParam param) {
        newsRepository.saveCreate(param);
    }

    @Override
    public void deleteNews(List<Long> ids) {
        newsRepository.deleteByIds(ids);
    }

    @Override
    public void sendNews(int id) {
        newsRepository.sendNews(id);
    }

}
